<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>06-ajax-get</title>
		<script type="text/javascript" src="myAjax.js"></script>
		 <script type="text/javascript">
			window.onload = function(ev)
			{
				var oBtn = document.querySelector("button");
				//encodeURIComponent 将中文转换为编码
				var res = encodeURIComponent("张三");
				console.log(res);
				oBtn.onclick = function(ev1)
				{
					//								%E5%BC%A0%E4%B8%89
					//	https://www.baidu.com/s?wd=%E5%BC%A0%E4%B8%89
					//url? key=value&key=value;
					ajax("04-ajax-get.php",{
						"userName":"yyf",
						"userPwd":"123456"
					},3000
					,function(xhr){
						alert(xhr.responseText);
					},function(xhr){
						alert("请求失败");
					});
				};
				
			};
		 </script>
	</head>
	<body>
	<button>发送请求</button>
	</body>
</html>
